package com.lottery.common.startup;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import com.lottery.module.api.impl.LotteryInfoProcesserImpl;
import com.lottery.module.service.LotteryInfoService;
import com.lottery.thrift.ThriftService;
import com.lottery.util.SpringUtil;

@Component
@Order(1)
public class StartupRunner
  implements CommandLineRunner
{

  @Value("${thrift.service.port}")
  private int thriftServicePort;

  public void run(String... args)
    throws Exception
  {
    System.out.println("加载启动参数：" + args);

    LotteryInfoService lotteryInfoService = (LotteryInfoService)SpringUtil.getBean("lotteryInfoService");
    lotteryInfoService.startNextLottery();

    ThriftService.start(LotteryInfoProcesserImpl.class, this.thriftServicePort);
  }
}